<template>
    <div class="word-com">
        <div class="header">
            <span class="title">灾害落区制作预览效果</span>
            <div class="btn-group">
                <el-button type="primary" size="small" icon="el-icon-download" @click="download">下载</el-button>
                <el-button plain size="small" icon="el-icon-back" @click="back">返回</el-button>
            </div>
        </div>

        <iframe class="iframe-word" :src="`http://10.226.127.40:8080/v1/officeOnline/officeView?path=${realPath}`"></iframe>
    </div>
</template>

<script>
export default {
    name: 'WordCom',
    props: {
        httpUrl: {
            type: String,
            default: '',
        },
        realPath: {
            type: String,
            default: '',
        }
    },
    data() {
        return {
            
        }
    },
    methods: {
        download() {
            if (!this.httpUrl) return this.$message.error('没有需要下载的文件');
            window.open(this.httpUrl);
        },
        back() {
            this.$emit('back');
        },
    }
}
</script>

<style lang="less" scoped>
.word-com {
    position: relative;
    padding: 20px;
    width: 100%;
    height: 100%;
    background-color: #ffffff;

    .header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        
        .title {
            font-weight: 700;
            color: #2885e3;
        }
    }

    .iframe-word {
        border: 1px solid #e5e5e5;
        margin-top: 20px;
        width: 100%;
        height: calc(100% - 55px);
    }
}
</style>
